Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Change to a Rails 4 ActiveModel validator. #11

Closed
wants to merge 1 commit into from

Conversation

schwern
Copy link

@schwern schwern commented Feb 17, 2020

Closes #10

Rails 4 introduced ActiveModel, ActiveModel::Validations and ActiveModel::EachValidator. Instead of injecting ourselves into ActiveRecord::Base, we will be automatically picked up.

We can now also be used on ActiveModel as well as ActiveRecord. This simplifies testing.

This does mean it requires at least Rails 4. If that's unacceptable I can add a shim for Rails 3.

Also

  • rspec-rails was dropped because it seems to want all of Rails loaded.
    We only needed one convenience method, errors_on. It has been copied into our test model.
  • Bumped our runtime dependency to activemodel >= 4.0. Dropped the others.
  • Dropped the development dependency on all of Rails. We only need ActiveModel.

Rails 4 introduced ActiveModel, ActiveModel::Validations and
ActiveModel::EachValidator.

Instead of injecting ourselves into ActiveRecord::Base, we will be
automatically picked up. This fixes KimNorgaard#1.

We can now also be used on ActiveModel as well as ActiveRecord. This
simplifies testing.

Also
* rspec-rails was dropped becasue it seems to want all of Rails loaded.
  We only needed one convenience method, errors_on. It has been copied into our test model.
* Bumped our runtime dependency to activemodel >= 4.0. Dropped the others.
* Dropped the development dependency on all of Rails. We only need ActiveModel.
@schwern schwern closed this Feb 17, 2020
@schwern schwern deleted the issue/#1 branch February 17, 2020 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calling ActiveRecord::Base.send(:include, PAK::ValidatesHostname) has side effects
1 participant